package com.tanhua.dubbo.server.api;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.User;
import com.tanhua.dubbo.server.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;

@Service(version = "1.0.0")
public class UserServiceImpl implements UserApi {

    @Autowired
    private UserMapper userMapper;

    public User findOne(QueryWrapper wrapper) {
        return this.userMapper.selectOne(wrapper);
    }

    @Override
    public User findByMobile(String mobile) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("mobile", mobile);
        return userMapper.selectOne(queryWrapper);
    }

    public Long insert(User user) {
        this.userMapper.insert(user);
        return user.getId();
    }

    public void update(User user) {
        this.userMapper.updateById(user);
    }
}
